//
//  SIXClassViewCell.m
//  FastDoctor_6
//
//  Created by cool on 16/3/3.
//  Copyright © 2016年 cool. All rights reserved.
//

#import "SIXClassViewCell.h"
#import "SIXClassModel.h"

@interface SIXClassViewCell()

@property (nonatomic, weak) UIImageView *icon;

@property (nonatomic, weak) UILabel *nameLabel;

@end

@implementation SIXClassViewCell


- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        
        //添加imageView
        UIImageView *icon = [[UIImageView alloc] init];
        
        self.icon = icon;
        [self.contentView addSubview:icon];
        
        //添加label
        UILabel *label = [[UILabel alloc] init];
        
        self.nameLabel = label;
        
        label.font = [UIFont systemFontOfSize:14];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [UIColor blackColor];
        
        label.text = @"肿瘤";
        
        [self.contentView addSubview:label];
        
    }
    return self;
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    CGSize cellSize = self.contentView.frame.size;
    CGFloat iconWidth = 40;
    CGFloat iconX = (cellSize.width - iconWidth) / 2;
    CGFloat iconY = (cellSize.height - 60) / 2;
    _icon.frame = CGRectMake(iconX, iconY, iconWidth, iconWidth);
    
    _nameLabel.frame = CGRectMake(0, CGRectGetMaxY(_icon.frame), cellSize.width, 20);
    
}

- (void)setClassModel:(SIXClassModel *)classModel{
    
    _icon.image = [UIImage imageNamed:classModel.icon];
    
    _nameLabel.text = classModel.name;

}


@end
